﻿<%@ Page Language="C#" MasterPageFile="~/MasterPages/AdminMasterPage.master" CodeBehind="ListDetails.aspx.cs"
    Inherits="RMS.Admin.ListDetails" %>

<%@ Register Src="~/Admin/DynamicData/Content/GridViewPager.ascx" TagName="GridViewPager"
    TagPrefix="asp" %>
<asp:Content ID="Content1" ContentPlaceHolderID="PagContent" runat="Server">
    <asp:DynamicDataManager ID="DynamicDataManager1" runat="server" AutoLoadForeignKeys="true">
        <DataControls>
            <asp:DataControlReference ControlID="FormView1" />
            <asp:DataControlReference ControlID="GridView1" />
        </DataControls>
    </asp:DynamicDataManager>
    <table class="Details" cellpadding="0" cellspacing="0">
        <tr>
            <td class="header" colspan="2">
                <%= table.DisplayName %>
            </td>
        </tr>
        <asp:UpdatePanel ID="UpdatePanel1" runat="server">
            <ContentTemplate>
                <div>
                    <asp:DynamicValidator runat="server" ID="GridViewValidator" ControlToValidate="GridView1"
                        Display="None" CssClass="DDValidator" />
                    <asp:DynamicValidator runat="server" ID="FormViewValidator" ControlToValidate="FormView1"
                        Display="None" CssClass="DDValidator" />
                    <asp:QueryableFilterRepeater runat="server" ID="FilterRepeater">
                        <ItemTemplate>
                            <asp:Label runat="server" Text='<%# Eval("DisplayName") %>' OnPreRender="Label_PreRender" />
                            <asp:DynamicFilter runat="server" ID="DynamicFilter" OnFilterChanged="DynamicFilter_FilterChanged" />
                        </ItemTemplate>
                    </asp:QueryableFilterRepeater>
                </div>
                <tr>
                    <td colspan="2">
                        <asp:GridView ID="GridView1" runat="server" DataSourceID="GridDataSource" EnablePersistedSelection="true"
                            AutoGenerateSelectButton="True" AutoGenerateEditButton="True" AutoGenerateDeleteButton="true"
                            AllowPaging="True" AllowSorting="True" OnDataBound="GridView1_DataBound" OnRowEditing="GridView1_RowEditing"
                            OnSelectedIndexChanging="GridView1_SelectedIndexChanging" OnRowDeleted="GridView1_RowDeleted"
                            OnRowUpdated="GridView1_RowUpdated" OnRowCreated="GridView1_RowCreated" CssClass="DDGridView">
                            <PagerStyle CssClass="DDFooter" />
                            <SelectedRowStyle CssClass="DDSelected" />
                            <PagerTemplate>
                                <asp:GridViewPager runat="server" />
                            </PagerTemplate>
                            <EmptyDataTemplate>
                                There are currently no items in this table.
                            </EmptyDataTemplate>
                        </asp:GridView>
                    </td>
                </tr>
                <asp:LinqDataSource ID="GridDataSource" runat="server" EnableDelete="true" EnableUpdate="true" />
                <asp:QueryExtender ID="GridQueryExtender" TargetControlID="GridDataSource" runat="server">
                    <asp:DynamicFilterExpression ControlID="FilterRepeater" />
                </asp:QueryExtender>
                <asp:Panel ID="DetailsPanel" runat="server">
                    <asp:FormView ID="FormView1" runat="server" DataSourceID="DetailsDataSource" RenderOuterTable="false"
                        OnPreRender="FormView1_PreRender" OnModeChanging="FormView1_ModeChanging" OnItemUpdated="FormView1_ItemUpdated"
                        OnItemInserted="FormView1_ItemInserted" OnItemDeleted="FormView1_ItemDeleted">
                        <ItemTemplate>
                            <tr>
                                <td>
                                    <asp:DynamicEntity runat="server" />
                                </td>
                                <td>
                                    <asp:LinkButton runat="server" CommandName="Edit" Text="Edit" />
                                    <asp:LinkButton runat="server" CommandName="Delete" Text="Delete" OnClientClick='return confirm("Are you sure you want to delete this item?");' />
                                    <asp:LinkButton runat="server" CommandName="New" Text="New" />
                                </td>
                            </tr>
                        </ItemTemplate>
                        <EditItemTemplate>
                            <tr>
                                <td>
                                    <asp:DynamicEntity runat="server" Mode="Edit" />
                                </td>
                                <td>
                                    <asp:LinkButton runat="server" CommandName="Update" Text="Update" />
                                    <asp:LinkButton runat="server" CommandName="Cancel" Text="Cancel" CausesValidation="false" />
                                </td>
                            </tr>
                        </EditItemTemplate>
                        <InsertItemTemplate>
                            <tr>
                                <td>
                                    <asp:DynamicEntity runat="server" Mode="Insert" />
                                </td>
                                <td>
                                    <asp:LinkButton runat="server" CommandName="Insert" Text="Insert" />
                                    <asp:LinkButton runat="server" CommandName="Cancel" Text="Cancel" CausesValidation="false" />
                                </td>
                            </tr>
                        </InsertItemTemplate>
                    </asp:FormView>
                    <asp:LinqDataSource ID="DetailsDataSource" runat="server" EnableDelete="true" EnableInsert="true"
                        EnableUpdate="true" />
                    <asp:QueryExtender TargetControlID="DetailsDataSource" runat="server">
                        <asp:ControlFilterExpression ControlID="GridView1" />
                    </asp:QueryExtender>
                </asp:Panel>
                <tr>
                    <td colspan="2" class="footer">
                        <asp:ValidationSummary ID="ValidationSummary1" runat="server" EnableClientScript="true" />
                    </td>
                </tr>
            </ContentTemplate>
        </asp:UpdatePanel>
    </table>
</asp:Content>
